package dhy.com.client;


import dhy.com.container.RpcContainerImpl;
import dhy.com.container.RpcContainerScanner;
import dhy.com.exception.RpcContainerException;



/**
 * <p>
 *     客户端连接管理器的实现类
 * </p>
 * @author zdh
 */
public class RpcClientManagerImpl extends AbstractRpcClientManager{
    /**
     * rpc容器类
     */
    private RpcContainerImpl rpcContainer;

    /**
     * rpc容器扫描器类
     */
    private RpcContainerScanner rpcContainerScanner;

    /**
     * 初始化rpc容器和rpc容器扫描器类
     */
    @Override
    public void beforeBuildConnection() {
       rpcContainer=new RpcContainerImpl();
        try {
            rpcContainerScanner = new RpcContainerScanner(rpcContainer);
            //查看是否开启了rpc远程调用服务
            isEnableRpcServer = rpcContainerScanner.isEnableRpcServer();
        } catch (RpcContainerException e) {
            e.printStackTrace();
        }
    }


    /**
     * 扫描client注解
     */
    @Override
    public void afterBuildConnection() {
        rpcContainerScanner.scannerClient();
    }


    @Override
    public void afterCloseConnection() {
       rpcContainer.destoryRpcContainer();
    }
}
